<?php

    class Main extends MY_Controller
    {
        public function __construct()
        {
            parent::__construct();
            $this->load->model('admin/user_model');
        }
        public function index()
        {
            $this->load->view('admin/main/index');
        }
        public function login()
        {
            $this->load->model('admin/user_model');
            $username=$this->input->post('username');
            $password=$this->input->post('password');
            $data=$this->user_model->getUserForLogin($username,$password);
            if(!empty($data))
            {
                $this->session->set_userdata('user',$data);
                redirect(base_url()."admin/product");
            }
            else
            {
                redirect(base_url()."admin/main");
            }
        }
        public function logout()
        {
            $this->session->unset_userdata('user');
            $this->session->sess_destroy();
            redirect(base_url()."admin/main");
        }
    }